package fr.axones.pocketagile.services.remote
{	
	import flash.net.URLRequestMethod;
	
	import fr.axones.pocketagile.services.remote.util.ResultHandler;
	import fr.axones.pocketagile.vo.ProjectVO;
	import fr.axones.pocketagile.vo.UserVO;
	
	import mx.rpc.AsyncToken;
	
	import org.spicefactory.lib.reflect.types.Void;

	public class ProjectService
	{
		public function ProjectService()
		{
		}
		
		/**
		 * Add the project
		 */
		public function addProject(project:ProjectVO, userId:Number):AsyncToken
		{
			var result:ResultHandler = new ResultHandler();
			
			result.doPost("http://axplanningpoker.appspot.com/rest/project",JSON.stringify(project) + "_@_" + userId);
			
			return result.token;
		}
		
		/**
		 * Delete the project
		 */
		public function deleteProject(projectId:Number):AsyncToken
		{
			var result:ResultHandler = new ResultHandler();
			
			result.doDelete("http://axplanningpoker.appspot.com/rest/project/"+projectId);
			
			return result.token;
		}
		
		/**
		 * Update the project
		 */
		public function updateProject(project:ProjectVO):AsyncToken
		{
			var result:ResultHandler = new ResultHandler();
			
			result.doPut("http://axplanningpoker.appspot.com/rest/project",JSON.stringify(project));
			
			return result.token;
		}
		
		/**
		 * Get all projects
		 */
		public function getProjects(userId:Number):AsyncToken
		{
			var result:ResultHandler = new ResultHandler();
			
			result.doGet("http://axplanningpoker.appspot.com/rest/projects/"+userId);

			return result.token;
		}
	}
}